function printf(...) 
	io.write(string.format(unpack(arg))) 
end

function ltrim(s)
  return (s:gsub("^%s*", ""))
end

function rtrim(s)
  local n = #s
  while n > 0 and s:find("^%s", n) do n = n - 1 end
  return s:sub(1, n)
end

function trim_string(s)
	return rtrim(ltrim(s))
end

function headerGuard(fileHandle,guardName)
	fileHandle:write("\#ifndef " ..guardName .. " \n\#\tdefine " ..guardName .. "\n")
end

function includeHeader(fileHandle,includeFile,angleBracket)
	local str = "\#\tinclude "
	local startBracket = "\"" 
	local endBracket = startBracket
	
	if(angleBracket == true)then 
		startBracket = "<"
		endBracket =">"
	end
	
	str = str ..startBracket ..includeFile ..endBracket .."\n"
	fileHandle:write(str)
end

function externCstart(fileHandle)
	fileHandle:write("extern \"C\"\n{\n")
end

function externCend(fileHandle)
	fileHandle:write("}/*end extern C*/\n")
end